package com.zenithmind.user.pojo.domain;

import com.zenithmind.common.base.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import io.swagger.v3.oas.annotations.media.Schema;
import com.baomidou.mybatisplus.annotation.*;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;

import java.time.LocalDateTime;

import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;

@EqualsAndHashCode(callSuper = true)
@Data
@AllArgsConstructor
@NoArgsConstructor
@Schema(name = "用户实体", description = "用户实体")
@TableName("user")
public class User extends BaseEntity {

    @NotBlank(message = "用户名不能为空", groups = {RegisterValidation.class})
    @Size(min = 3, max = 50, message = "用户名长度必须在3到50之间", groups = {RegisterValidation.class})
    @Schema(description = "用户名")
    private String username;

    @NotBlank(message = "密码不能为空", groups = {RegisterValidation.class})
    @Size(min = 6, message = "密码长度至少为6位", groups = {RegisterValidation.class})
    @Schema(description = "密码")
    private String password;

    @Size(max = 50, message = "昵称长度不能超过50个字符")
    @Schema(description = "昵称")
    private String nickname;

    @Schema(description = "头像 URL")
    private String avatar;

    @Email(message = "邮箱格式不正确")
    @Size(max = 100, message = "邮箱长度不能超过100个字符")
    @Schema(description = "邮箱")
    private String email;

    @Schema(description = "手机号")
    private String mobile;

    @Schema(description = "状态 (0-禁用, 1-启用)")
    private Integer status;

    @Schema(description = "最后登录时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime lastLoginTime;

    @Schema(description = "最后登录IP")
    private String lastLoginIp;

    @Schema(description = "个人简介")
    @Size(max = 255, message = "个人简介长度不能超过255个字符")
    private String intro;

    /**
     * 已用存储空间，单位字节
     */
    private Long storageUsed;

    /**
     * 总存储空间限制，单位字节 (null 或 -1 表示无限制)
     */
    @Schema(description = "总存储空间限制，单位字节 (null 或 -1 表示无限制)")
    private Long storageLimit;

    public interface RegisterValidation {}
}
